'use strict';
import React from 'react';
import {
    View,
    ListView
} from 'react-native';
import ToolBar from '../Components/ToolBar';
import RenderShopItem from '../Components/RenderShopItem';
import SpecialtyDetailsPage from '../Pages/SpecialtyDetailsPage';
import RuralLibraryAPIService from '../Commom/RuralLibraryAPIService';
class AllGoodsPage extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            dataSource: new ListView.DataSource({
                rowHasChanged: (r1, r2) => r1 !== r2,
            })
        }
    }

    componentDidMount() {
        let id = this.props.ID;
        RuralLibraryAPIService.getStoreFoot(id).then((ret)=> {
            this.setState({
                dataSource: this.state.dataSource.cloneWithRows(ret),
            });
        }).catch((err)=> {

        });
    }

    onItemClick(id) {
        this.props.navigator.push({
            name: 'SpecialtyDetailsPage',
            component: SpecialtyDetailsPage,
            passProps: {
                ID: id
            }
        });
    }

    render() {
        return (
            <View style={{flex: 1,backgroundColor:'white'}}>
                <ToolBar leftFunc={()=>this.props.navigator.pop()} title="全部商品" rightFunc={() => {
                }} rightImage={0}/>
                <ListView
                    dataSource={this.state.dataSource}
                    renderRow={(rowData)=> {
                        return <RenderShopItem activeOpacity={0} onItemPress={(id) => this.onItemClick(id)} {...rowData}/>
                    }}
                />
            </View>
        )
    }
}

export default AllGoodsPage;